package com.sudo.common.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;

/**
 * @author 为道日损 2020-05-06 23:57
 * webSite：https://www.sudo.ren
 */
public class RetResponse {

    public static void res(HttpServletResponse response, JsonRes jsonRes) {

        OutputStream out = null;
        try {
            response.setCharacterEncoding("utf-8");
            response.setContentType("application/json");
            out = response.getOutputStream();
            out.write(JsonUtil.objectToJson(jsonRes).getBytes("utf-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                if (null != out) {
                    out.close();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}
